import redis
from config.redis_config import REDIS_CONFIG

class RedisHelper:
    """Redis操作助手类"""
    
    def __init__(self):
        self.redis_client = redis.Redis(
            host=REDIS_CONFIG['host'],
            port=REDIS_CONFIG['port'],
            password=REDIS_CONFIG['password'],
            db=REDIS_CONFIG['db'],
            decode_responses=REDIS_CONFIG['decode_responses']
        )
    
    def set_value(self, key, value, expire=None):
        """设置键值对"""
        self.redis_client.set(key, value, ex=expire)
    
    def get_value(self, key):
        """获取值"""
        return self.redis_client.get(key)
    
    def delete_key(self, key):
        """删除键"""
        self.redis_client.delete(key)
    
    def exists_key(self, key):
        """检查键是否存在"""
        return self.redis_client.exists(key) 